from LinkedList import *

def addTwoNum(numA, numB):
    """

    :type numA: LinkedList<int>
    :type numB: LinkedList<int>
    :rtype: LinkedList<int>
    """
    if numA.isEmpty():
        return numB;
    elif numB.isEmpty():
        return numA;
    else:
        result = LinkedList();
        carry = 0;
        curA = numA.head;
        curB = numB.head;
        while curA is not None or curB is not None:
            
            digA = 0;
            if curA is not None:
                digA = curA.data;
            digB = 0;
            if curB is not None:
                digB = curB.data;
            temp = carry + digA + digB;
            result.append(temp % 10);
            carry = temp // 10;
            if curA is not None:
                curA = curA.next;
            if curB is not None:
                curB = curB.next;
        else:
            if carry > 0:
                result.append(carry);
            print("Finish");
        return result;
